package DBLayer;

import static org.junit.Assert.*;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import ModelLayer.*;

public class DBBetalingTest {
	private DBBetaling dbBetal;

	@Before
//	public void setUp() throws Exception {
//		dbBetal = new DBBetaling();
//	}

	@After
	public void tearDown() throws Exception {
	}
	
	/**
	 * Test method for {@link DBLayer.DBBetaling#getAllBetalinger(boolean)}.
	 */
	@Test
	public void testGetAllBetalinger() 
	{
		dbBetal.getAllBetalinger(true);
	}

	/**
	 * Test method for {@link DBLayer.DBBetaling#findBetalingId(int, boolean)}.
	 */
	@Test
	public void testFindBetalingId() {
		
		Betaling bObject = dbBetal.getBetalingId(999, false);
			if(bObject != null)
			{
				System.out.print("\n SalgsId:	" + bObject.getBetalId() +  "\n Betalingsdato:	" + bObject.getBetalingsDato() + "\n Totalpris:	" + bObject.getTotalPris() + "\n Status:	" + bObject.getBetalingsStatus());
			}
			fail("Betaling not found");
		}
	

	/**
	 * Test method for {@link DBLayer.DBBetaling#insertBetaling(ModelLayer.Betaling)}.
	 * @throws Exception 
	 */
	@Test
	public void testInsertBetaling() throws Exception {
		
		Betaling bObject = new Betaling(1000,"2012/05/15",250.00, false);
		dbBetal.insertBetaling(bObject);
		//Normally you would delte the betaling after inserting in an insert test but because we wanted to find the betaling afterwords the delete was not implemented
	}

	/**
	 * Test method for {@link DBLayer.DBBetaling#updateBetaling(ModelLayer.Betaling)}.
	 */
	@Test
	public void testUpdateBetaling() {
		double bet = 150.00;
		Betaling bObject = dbBetal.getBetalingId(999, false);
		bObject.setTotalPris(bet);
		bObject.setBetalingsStatus(false);
		
		dbBetal.updateBetaling(bObject);		
	}
}
